<template>
    <rx-dialog @handOk="handSubmit"  @cancel="cancel">
        <rx-layout>
            <div slot="center">
                <a-form-model ref="form"  :model="mdl" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
                    <a-form-model-item  :label="i18n('form.name','名字')" prop = "name">
                        <a-input :placeholder="i18n('form.name','名字','input')" v-model="mdl.name" length="1" multiple="false"/>
                    </a-form-model-item>

                    <a-form-model-item  :label="i18n('form.seal','图章')" prop = "fileId">
                        <rx-simple-attachment v-model="fileJson" file-type="image" :length="1"></rx-simple-attachment>
                    </a-form-model-item>

                    <a-form-model-item  :label="$ti18('rxForm.type', '类型')" prop = "type">
                        <rx-select  v-model="mdl.type"
                            url="/api-system/system/core/sysDic/treeByKey?key=stampType"
                                   value-field="value" text-field="name"
                        ></rx-select>

                    </a-form-model-item>
                    <a-form-model-item  :label="$ti18('rxForm.notes', '备注')" prop = "comment">
                        <a-textarea :placeholder="$ti18('rxForm.notes', '备注','','input')" v-model="mdl.comment"/>
                    </a-form-model-item>
                </a-form-model>


            </div>
        </rx-layout>
    </rx-dialog>
</template>
<script>
    import FormStampApi from '@/api/form/core/formStamp.js'
    import {RxDialog,BaseFormModel,RxSimpleAttachment,RxSelect} from "@lowcode/jpaas-common-lib";


    export default {
        name: 'FormStampEdit',
        mixins:[BaseFormModel],
        components: {
            RxDialog,
            "rx-simple-attachment":RxSimpleAttachment,
            RxSelect
        },
        data(){
            return {
                mdl:{
                    name:"",
                    type:"",
                    comment:"",
                    fileJson:[]
                },
                fileJson:[],
                /**
                 * 子表列表，以及表格属性
                 */
                subTable:{},
                rules: {
                    comment: [{ required:false,message:this.$ti18('rxForm.notes', '备注','','input'), trigger: 'change' }],
                    name: [{ required:true,message:this.i18n('form.name','名字','input'), trigger: 'change' }],
                    type: [{ required:true,message:this.$ti18('rxForm.type', '类型','','select'), trigger: 'change' }]
                }
            }
        },
        methods: {
            handSubmit(vm){
                vm.loading = false ;
                this.handleSubmit(vm)
            },
            i18n(name, text, key) {
                return this.$ti18(name, text, "formStamp", key);
            },
            demo(){
                console.info(this.fileJson);
            },
            get(id){
                return FormStampApi.get(id);
            },
            onload_(data){
              if(data){
                  this.fileJson=JSON.parse( data.fileJson);
              }
            },
            save(){
                this.mdl.fileJson=JSON.stringify(this.fileJson);
                return FormStampApi.save(this.mdl);
            }

        }
    }
</script>
<style>
    .relick a{
        margin-right: 10px;
    }

</style>
